﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.Windows.Forms;

public partial class EmeployInfoList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (TextBox2.Text == "")
        {            
            SqlConnection conn;
            conn = new SqlConnection(ConfigurationManager.ConnectionStrings["graduate_manageConnectionString2"].ConnectionString);
            conn.Open();
            SqlCommand comm1 = new SqlCommand("select GRA_NAME,GRA_ID,GRA_SEX,GRA_MAJOR,GRA_EMAIL from INFO_GRADUATE ", conn);
            SqlDataAdapter adapter = new SqlDataAdapter(comm1);
            DataSet ds = new DataSet();
            adapter.Fill(ds);
            GridView1.DataSource = ds.Tables[0].DefaultView;
            GridView1.DataBind();
            conn.Close();
        }
    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        String ID = this.GridView1.SelectedRow.Cells[1].Text.ToString();
        Session["id"] = ID;
        Response.Redirect("GraduateDetails.aspx");
        
    }
    protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
    {
        this.GridView1.DataBind();
    }
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        Response.Redirect("SelfInfo.aspx");
    }
    protected void TextBox2_TextChanged(object sender, System.EventArgs e)
    {
        
    }
    protected void Button2_Click(object sender, System.EventArgs e)
    {
        SqlConnection conn;
        conn = new SqlConnection(ConfigurationManager.ConnectionStrings["graduate_manageConnectionString2"].ConnectionString);
        conn.Open();
        SqlCommand comm = new SqlCommand("select GRA_ID,GRA_NAME,GRA_SEX,GRA_MAJOR,GRA_EMAIL from INFO_GRADUATE where GRA_ID='" + TextBox2.Text + "'", conn);
        SqlDataAdapter adapter = new SqlDataAdapter(comm);
        DataSet ds = new DataSet();
        adapter.Fill(ds);
        GridView1.DataSource = ds.Tables[0].DefaultView;
        GridView1.DataBind();
        conn.Close();
    }
}